﻿Public Class NhaCungCapDAO
    Public Shared Function LoadNhaCungCap() As DataTable
        Dim dt As DataTable = Nothing
        Dim strSQL As String = "select * from NhaCungCap ncc"
        Dim dp As DataProvider = New DataProvider()
        dt = dp.ExecuteQuery(strSQL)
        Return dt
    End Function
    Public Shared Sub ThemNhaCungCap(ByVal _ncc As NhaCungCap)
        Dim strSQL As String = "insert into NhaCungCap(ncc_Ten,ncc_DiaChi,ncc_SoDienThoai) values ('" & _ncc.m_strTen & " ','" & _ncc.m_strDiaChi & "','" & _ncc.m_strSoDienThoai & "')"
        Dim dp As DataProvider = New DataProvider()
        dp.ExecuteNonQuery(strSQL)
    End Sub
    Public Shared Function XoaNhaCungCap(ByVal _ncc As NhaCungCap)
        Dim dt As DataTable = Nothing
        Dim strSQL As String = "delete from NhaCungCap where ncc_Ten = '" + _ncc.m_strTen + "'"
        Dim dp As DataProvider = New DataProvider()
        dt = dp.ExecuteQuery(strSQL)
        Return dt
    End Function
    Public Shared Sub CapNhatNhaCungCap(ByRef _ncc As NhaCungCap)
        Dim strSQL As String = "UPDATE NhaCungCap set ncc_Ten = '" & _ncc.m_strTen & "', ncc_DiaChi = '" & _ncc.m_strDiaChi & "',ncc_SoDienThoai = '" & _ncc.m_strSoDienThoai & "' where ncc_ID = " & _ncc.m_intID & ""
        Dim dp As DataProvider = New DataProvider()
        dp.ExecuteNonQuery(strSQL)
    End Sub
    Public Shared Function TimKiemNhaCungCap(ByRef _ncc As NhaCungCap)
        Dim dt As DataTable = Nothing
        Dim strSQL As String = "select * from NhaCungCap  where ncc_Ten like '%" & _ncc.m_strTen & "%'"
        Dim dp As DataProvider = New DataProvider()
        dt = dp.ExecuteQuery(strSQL)
        Return dt
    End Function
End Class
